package com.ray.client;
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import com.ray.basic.BASIC;
public class Client_out extends BASIC implements Runnable{
	private OutputStream out;
	private static BlockingQueue<String> bQueue = new LinkedBlockingQueue<String>();
	public Client_out(){}
	public Client_out(OutputStream out){
		this.out=out;
	}
	public void run(){
		while(new Client_in().get_status()){
			if (!bQueue.isEmpty()){
				String information=bQueue.peek();
				bQueue.remove();
				byte[] sendBuf= this.pack(information);
				try {
					out.write(sendBuf);
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					break;
				}
			}
		}
		System.out.println("quit successfully");
	}
	public BlockingQueue<String> get_Queue(){
		return bQueue;
	}
}
